package com.yidu.ladder.system.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.ladder.system.domain.OrgVo;
import com.yidu.ladder.system.service.OrgService;

/**
 *  组织结构控制器层
 * @since 2019年11月26日
 * @author {群主老王}
 */
@Controller
@RequestMapping("/sys/org/")
public class OrgController {
	
	@Autowired
	private OrgService orgSevirce;
	
	public OrgController() {}

	public OrgService getOrgSevirce() {
		return orgSevirce;
	}

	public void setOrgSevirce(OrgService orgSevirce) {
		this.orgSevirce = orgSevirce;
	}
	
	/**
	 *  添加组织结构信息
	 * @param orgVo 组织结构包装类
	 * @return 添加成功返回1，否则返回0
	 */
	@RequestMapping(value = "add", method = RequestMethod.POST)
	@ResponseBody
	public int insert(OrgVo orgVo) {
		return orgSevirce.insert(orgVo);
	}
	
	/**
	 *  修改组织结构信息
	 * @param orgVo 组织结构包装类
	 * @return 修改成功返回1，否则返回0
	 */
	@RequestMapping(value = "update", method = RequestMethod.POST)
	@ResponseBody
	public int update(OrgVo orgVo) {
		return orgSevirce.update(orgVo);
	}
	
	/**
	 *  根据id删除组织结构信息
	 * @param orgId 组织结构id
	 * @return 删除成功返回1，否则返回0
	 */
	@RequestMapping(value = "delete/{orgIds}", method = RequestMethod.DELETE)
	@ResponseBody
	public int delete(@PathVariable("orgIds") String orgIds) {
		return orgSevirce.delete(orgIds);
	}
	
	/**
	 * 条件查询组织结构信息集合
	 * @param orgVo 组织结构包装类
	 * @return 组织结构对象集合
	 */
	@RequestMapping(value = "selectList", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> select(OrgVo orgVo) {
		return orgSevirce.select(orgVo);
	}

}
